import React from 'react'


class Welcome extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            date: new Date(),
        }
    }
    componentDidMount() {
        this.timerID = setInterval(() => this.tick(), 1000);
    }
    componentWillUnmount() {
        clearInterval(this.timerID);
    }
    tick() {
        this.setState({
            date: new Date(),
        })
    }
    render() {
      return <h1>
          Hello, {this.props.name}
          现在是: {this.state.date.toLocaleTimeString()}.
        </h1>;
      
    }
  }


  export default Welcome;